

import java.util.Scanner;

class SpojPrimeFinal {
	public static void main(String args[]) {

		// Get number of test cases
		int numTestCase;
		Scanner in = new Scanner(System.in);
		numTestCase = in.nextInt();

		if ((numTestCase < 1) || (numTestCase > 10)) {
			return;
		}

		long lowerBound, upperBound;
		while (numTestCase-- > 0) {
			lowerBound = in.nextInt();
			upperBound = in.nextInt();

			// Argument checking
			if ((upperBound > 1000000000)
					|| ((upperBound - lowerBound) > 100000)) {
				System.out.println();
				continue;
			}

			if (lowerBound < 2) {
				lowerBound = 2;
			}

			if ((upperBound < lowerBound) || (upperBound < 2)) {
				System.out.println();
				continue;
			}

			// Allocate prime numbers array and initialize it
			// Type casting to integer in purpose as the check above confirms
			// that the difference of upperBound and lowerBound < 100,000
			boolean primeNumbers[] = new boolean[(int) (upperBound - lowerBound + 1)];
			for (int i = 0; i < primeNumbers.length; i++) {
				primeNumbers[i] = true;
			}

			// Loop until square root of the largest number is enough for
			// striking of all non-primes
			for (long i = 2; i <= Math.ceil(Math.sqrt(upperBound)); i++) {
				// Continue the loop if the number is already marked as
				// non-prime.
				
				if ((i >= lowerBound) && (primeNumbers[(int) (i - lowerBound)] == false))
					continue;

				// Take largest of 2*i or the first number > lowerBound
				// divisible by i
				long j = (long) ((2 * i) > Math.ceil((double)lowerBound / i) * i ? (2 * i)
						: Math.ceil((double)lowerBound / i) * i);

				for (; j <= upperBound; j=j+i) {
					primeNumbers[(int) (j - lowerBound)] = false;
				}
			}

			for (int i = 0; i < primeNumbers.length; i++) {
				if (primeNumbers[i])
					System.out.println(lowerBound + i);
			}
			System.out.println();
		}
	}
}
